﻿/*
 * Created By: Bharati On 04-Oct-10 @ 16:17
 */
using System.Collections;
using System;

namespace Jas
{
	
	public class PersistableIdProvider<TElement>
	{
		Hashtable idTable;
		
		
		public PersistableIdProvider()
		{
			idTable=new Hashtable();
			
		}
		public Int32 count{
			get{
				return idTable.Count;
			}
		}
		
		
		public Int32 add(TElement element)
		{
			if(idTable.ContainsKey(element)) return (Int32)idTable[element];
			else {
				idTable.Add(element,idTable.Count);
				return (Int32)idTable[element];
			}
		}
		
		public Int32 this[TElement element]
		{
			get{
				return add(element);
			}
		}
		
	}
}
